package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-02 10:34
 **/
public class LeetCode2125 {

    public int numberOfBeams(String[] bank) {
        int count = 0;
        int pre = 0;
        for (String s : bank) {
            int count1 = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) - '0' == 1) {
                    ++count1;
                }
            }

            if (pre != 0 && count1 != 0) {
                count += pre * count1;
            }

            if (count1 != 0) {
                pre = count1;
            }
        }

        return  count;
    }

    public static void main(String[] args) {
        LeetCode2125 code = new LeetCode2125();
        System.out.println(code.numberOfBeams(new String[]{"011001", "000000", "010100", "001000"}));
        System.out.println(code.numberOfBeams(new String[]{"000","111","000"}));
    }

}
